<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body{
      background-color: #eee;
    }
    #app{
      background-color:#fff;
      width: 500px;
      margin: 50px auto;
      box-shadow: 3px 3px 3px rgba(0 , 0, 0, 0.5);padding:2em;
     }
    .box{
      padding: 1em;
      border:1px solid #ccc;
      margin:1em;
    }
    </style>
</head>

<body>
  <div id="app">
    <span>这里整个是父组件的地盘</span>
    <!-- 正常父传子： <com1 :a="num"></com1> -->
    <com1 v-model="num"></com1> 
  </div>
  <!-- 导入js文件 -->
  <script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
  <script>
        Vue.component('com1', {
      // props: ["a", "msg"],
      props: ['value'],
      template: `
      <div>
        我是子组件, {{value}}
        <button @click="btn">修改把父组件传递的数据+1</button>
      </div>
      `,
      methods: {
        btn () {
          this.$emit('input', this.value + 1)
          // this.a = this.a + 1
        }
      }
    })
    new Vue({
      el: "#app",
      data: {
        num: 1000,
        msg: '你好！'
      },
      methods: {
      }
    });
  </script>
</body>

</html>